import { dom } from "../tool";

interface FormItemType {
    label: string;
    item: HTMLElement | object;
}
interface PropsType {
    onChange?: (value: object)=>any;
    initValue?: object;
    childs?: FormItemType[];
}

interface FormType {
    new (props?:PropsType): FormType;
    onChange?: (value: object)=>any;
    value?: object;
    setValue: (value?: object)=>void;
    render: (node?:HTMLElement)=>HTMLElement;
}

function Form(this:FormType, props?:PropsType){
    const { initValue = {}, childs = [], onChange } = props || {};
    this.onChange = onChange;
    const container = dom('form', { className: 'gkh-form' });
    this.render = (node)=>{
        if(node instanceof Node){
            node.appendChild(container);
        }
        return container;
    }
    return this;
}

export default Form as unknown as FormType;

